<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>问答页面</title>
   <script src="path/to/local/jquery-3.6.0.min.js"></script>
</head>
<body>
<h1>星火认知大模型问答</h1>
<form id="question-form">
    <input type="text" id="user-input" placeholder="请输入问题...">
    <button type="submit">提问</button>
</form>
<div id="response"></div>
<script>
    $(document).ready(function() {
        $('#question-form').submit(function(event) {
            event.preventDefault(); 
            var userInput = $('#user-input').val(); 
            $.ajax({
                url: 'http://126.0.1.1:5000/chat', 
                type: 'POST', 
                contentType: 'application/json', 
                data: JSON.stringify({ user_input: userInput }), 
                success: function(response) { 
                    $('#response').text(response.response); 
                },
                error: function(error) {
    console.error('Error:', error);
    $('#response').text('发生错误：' + error.responseText);
}
                }
            });
        });
    });
</script>
</body>
</html>